package org.video.mine.utils;

import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.os.Looper;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.view.animation.AnimationUtils;
import android.view.animation.ScaleAnimation;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import org.video.mine.R;

public class Progress extends Dialog {

    public Progress(@NonNull Context context) {
        this(context, R.style.ProgressHUD);
    }

    public Progress(@NonNull Context context, int themeResId) {
        super(context, themeResId);
        init(context);
    }

    protected Progress(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    private void init(Context context){
        this.setTitle("");
        this.setContentView(R.layout.progress_dialog);
        ImageView imageView = this.findViewById(R.id.spinnerImageView);
        imageView.setBackgroundResource(R.drawable.spinner);
        AnimationDrawable background = (AnimationDrawable) imageView.getBackground();
        background.start();
        this.setCancelable(true);
        this.setCanceledOnTouchOutside(false);//触摸不消失
        this.getWindow().getAttributes().gravity = Gravity.CENTER;
        WindowManager.LayoutParams lp = this.getWindow().getAttributes();
        lp.dimAmount = 0.2f;
        this.getWindow().setAttributes(lp);
    }

}
